﻿using System.Text;
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释

namespace LoongEgg.Check
{
    /// <summary>
    /// CRC算法
    /// </summary>
    public partial class CrcAlgorithm
    {
        /// <summary>
        /// 标准参数
        /// </summary>
        public static class Standard
        {

            /// <summary>
            /// 验证用的标准输入, 即ASCII "123456789"
            /// </summary>
            /// <remarks>
            ///   使用Encoding.ASCII.GetBytes("123456789")获得的是new byte[9] {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39}
            /// </remarks>
            public static byte[] Validate => Encoding.ASCII.GetBytes("123456789");

            #region CRC-8

            public static CrcAlgorithm Crc8 { get; } = new CrcAlgorithm("CRC-8", 8, 0x07, 0x00, false, false, 0x00, 0xF4);
            public static CrcAlgorithm Crc8Cdma2000 { get; } = new CrcAlgorithm("CRC-8/CDMA2000", 8, 0x9B, 0xFF, false, false, 0x0, 0xDA);
            public static CrcAlgorithm Crc8Darc { get; } = new CrcAlgorithm("CRC-8/DARC", 8, 0x39, 0x0, true, true, 0x0, 0x15);
            public static CrcAlgorithm Crc8DvbS2 { get; } = new CrcAlgorithm("CRC-8/DVB-S2", 8, 0xD5, 0x0, false, false, 0x0, 0xBC);
            public static CrcAlgorithm Crc8Ebu { get; } = new CrcAlgorithm("CRC-8/EBU", 8, 0x1D, 0xFF, true, true, 0x0, 0x97);
            public static CrcAlgorithm Crc8ICode { get; } = new CrcAlgorithm("CRC-8/I-CODE", 8, 0x1D, 0xFD, false, false, 0x0, 0x7E);
            public static CrcAlgorithm Crc8Itu { get; } = new CrcAlgorithm("CRC-8/ITU", 8, 0x07, 0x00, false, false, 0x55, 0xA1);
            public static CrcAlgorithm Crc8Maxim { get; } = new CrcAlgorithm("CRC-8/MAXIM", 8, 0x31, 0x0, true, true, 0x0, 0xA1);
            public static CrcAlgorithm Crc8Rohc { get; } = new CrcAlgorithm("CRC-8/ROHC", 8, 0x7, 0xFF, true, true, 0x0, 0xD0);
            public static CrcAlgorithm Crc8Wcdma { get; } = new CrcAlgorithm("CRC-8/WCDMA", 8, 0x9B, 0x0, true, true, 0x0, 0x25);

            #endregion

            #region CRC-16
            public static CrcAlgorithm Crc16CcittFalse { get; } = new CrcAlgorithm("CRC-16/CCITT-FALSE", 16, 0x1021, 0xFFFF, false, false, 0x0000, 0x29B1);
            public static CrcAlgorithm Crc16Arc { get; } = new CrcAlgorithm("CRC-16/ARC", 16, 0x8005, 0x0, true, true, 0x0, 0xBB3D);
            public static CrcAlgorithm Crc16AugCcitt { get; } = new CrcAlgorithm("CRC-16/AUG-CCITT", 16, 0x1021, 0x1D0F, false, false, 0x0000, 0xE5CC);
            public static CrcAlgorithm Crc16Buypass { get; } = new CrcAlgorithm("CRC-16/BUYPASS", 16, 0x8005, 0x0, false, false, 0x0, 0xFEE8);
            public static CrcAlgorithm Crc16Cdma2000 { get; } = new CrcAlgorithm("CRC-16/CDMA2000", 16, 0xC867, 0xFFFF, false, false, 0x0, 0x4C06);
            public static CrcAlgorithm Crc16Dds110 { get; } = new CrcAlgorithm("CRC-16/DDS-110", 16, 0x8005, 0x800D, false, false, 0x0, 0x9ECF);
            public static CrcAlgorithm Crc16DectR { get; } = new CrcAlgorithm("CRC-16/DECT-R", 16, 0x589, 0x0, false, false, 0x1, 0x7E);
            public static CrcAlgorithm Crc16DectX { get; } = new CrcAlgorithm("CRC-16/DECT-X", 16, 0x589, 0x0, false, false, 0x0, 0x7F);
            public static CrcAlgorithm Crc16Dnp { get; } = new CrcAlgorithm("CRC-16/DNP", 16, 0x3D65, 0x0, true, true, 0xFFFF, 0xEA82);
            public static CrcAlgorithm Crc16En13757 { get; } = new CrcAlgorithm("CRC-16/EN-13757", 16, 0x3D65, 0x0, false, false, 0xFFFF, 0xC2B7);
            public static CrcAlgorithm Crc16Genibus { get; } = new CrcAlgorithm("CRC-16/GENIBUS", 16, 0x1021, 0xFFFF, false, false, 0xFFFF, 0xD64E);
            public static CrcAlgorithm Crc16Maxim { get; } = new CrcAlgorithm("CRC-16/MAXIM", 16, 0x8005, 0x0, true, true, 0xFFFF, 0x44C2);
            public static CrcAlgorithm Crc16Mcrf4Xx { get; } = new CrcAlgorithm("CRC-16/MCRF4XX", 16, 0x1021, 0xFFFF, true, true, 0x0, 0x6F91);
            public static CrcAlgorithm Crc16Riello { get; } = new CrcAlgorithm("CRC-16/RIELLO", 16, 0x1021, 0xB2AA, true, true, 0x0000, 0x63D0);
            public static CrcAlgorithm Crc16T10Dif { get; } = new CrcAlgorithm("CRC-16/T10-DIF", 16, 0x8BB7, 0x0, false, false, 0x0, 0xD0DB);
            public static CrcAlgorithm Crc16Teledisk { get; } = new CrcAlgorithm("CRC-16/TELEDISK", 16, 0xA097, 0x0, false, false, 0x0, 0xFB3);
            public static CrcAlgorithm Crc16Tms37157 { get; } = new CrcAlgorithm("CRC-16/TMS37157", 16, 0x1021, 0x89EC, true, true, 0x0, 0x26B1);
            public static CrcAlgorithm Crc16Usb { get; } = new CrcAlgorithm("CRC-16/USB", 16, 0x8005, 0xFFFF, true, true, 0xFFFF, 0xB4C8);
            public static CrcAlgorithm CrcA { get; } = new CrcAlgorithm("CRC-A", 16, 0x1021, 0xC6C6, true, true, 0x0, 0xBF05);
            public static CrcAlgorithm Crc16Kermit { get; } = new CrcAlgorithm("CRC-16/KERMIT", 16, 0x1021, 0x0, true, true, 0x0, 0x2189);
            public static CrcAlgorithm Crc16Modbus { get; } = new CrcAlgorithm("CRC-16/MODBUS", 16, 0x8005, 0xFFFF, true, true, 0x0000, 0x4B37);
            public static CrcAlgorithm Crc16X25 { get; } = new CrcAlgorithm("CRC-16/X-25", 16, 0x1021, 0xFFFF, true, true, 0xFFFF, 0x906E);
            public static CrcAlgorithm Crc16Xmodem { get; } = new CrcAlgorithm("CRC-16/XMODEM", 16, 0x1021, 0x0, false, false, 0x0, 0x31C3);

            #endregion

            #region CRC-32 
            public static CrcAlgorithm Crc32 { get; } = new CrcAlgorithm("CRC-32", 32, 0x04C11DB7, 0xFFFFFFFF, true, true, 0xFFFFFFFF, 0xCBF43926);
            public static CrcAlgorithm Crc32Bzip2 { get; } = new CrcAlgorithm("CRC-32/BZIP2", 32, 0x04C11DB7, 0xFFFFFFFF, false, false, 0xFFFFFFFF, 0xFC891918);
            public static CrcAlgorithm Crc32C { get; } = new CrcAlgorithm("CRC-32C", 32, 0x1EDC6F41, 0xFFFFFFFF, true, true, 0xFFFFFFFF, 0xE3069283);
            public static CrcAlgorithm Crc32D { get; } = new CrcAlgorithm("CRC-32D", 32, 0xA833982B, 0xFFFFFFFF, true, true, 0xFFFFFFFF, 0x87315576);
            public static CrcAlgorithm Crc32Jamcrc { get; } = new CrcAlgorithm("CRC-32/JAMCRC", 32, 0x04C11DB7, 0xFFFFFFFF, true, true, 0x00000000, 0x340BC6D9);
            public static CrcAlgorithm Crc32Mpeg2 { get; } = new CrcAlgorithm("CRC-32/MPEG-2", 32, 0x04C11DB7, 0xFFFFFFFF, false, false, 0x00000000, 0x0376E6E7);
            public static CrcAlgorithm Crc32Posix { get; } = new CrcAlgorithm("CRC-32/POSIX", 32, 0x04C11DB7, 0x00000000, false, false, 0xFFFFFFFF, 0x765E7680);
            public static CrcAlgorithm Crc32Q { get; } = new CrcAlgorithm("CRC-32Q", 32, 0x814141AB, 0x00000000, false, false, 0x00000000, 0x3010BF7F);
            public static CrcAlgorithm Crc32Xfer { get; } = new CrcAlgorithm("CRC-32/XFER", 32, 0x000000AF, 0x00000000, false, false, 0x00000000, 0xBD0BE338);
            #endregion
        }
    }
}
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
